'use strict';

const dayjs = require('dayjs');

module.exports = app =>{
    const { STRING, INTEGER, DATE } = app.Sequelize;

    const subscribe = app.model.define('subscribe',{
        id: {
          type: INTEGER, primaryKey: true, autoIncrement: true,
        },
        be_subscribe_id:INTEGER(4),
        subscribe_id:INTEGER(4),
        status:INTEGER(4),
        create_time:{
            type:DATE,
            get(){
                const time = this.getDataValue('create_time');
                return time ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') : null
            }
        },
        delete_time:{
            type:DATE,
            get(){
                const time = this.getDataValue('delete_time');
                return time ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') : null
            }
        }
    },{
        freezeTableName: false,
        tableName: 'subscribe',
        underscored: false,
        paranoid: true,
        timestamps: true,
        createdAt: false,
        updatedAt: false,
        deletedAt: 'delete_time',
    })
    return subscribe;
}